package com.faxsun.web.endpoint.entity;

import java.util.ArrayList;
import java.util.List;

import mtons.modules.pojos.Page;

import com.faxsun.core.persist.entity.LiveMsgPO;

/**
 * 消息实体聚合
 * @author songdragon 2015年6月18日
 *
 */
public class LiveMsgsJSON {
	public int total;
	public int pageNo;
	public int pageSize;
	public int maxPage;
	public List<LiveMsgJSON> msgs;

	public static LiveMsgsJSON parse(Page page) {
		LiveMsgsJSON json = new LiveMsgsJSON();
		json.msgs = new ArrayList<LiveMsgJSON>();
		@SuppressWarnings("unchecked")
		List<LiveMsgPO> result = (List<LiveMsgPO>) page.getResults();
		for (LiveMsgPO po : result) {
			json.msgs.add(LiveMsgJSON.parse(po));
		}
		json.total = page.getTotalCount();
		json.maxPage = page.getPageCount();
		json.pageNo = page.getPageNo();
		json.pageSize = page.getSize();
		return json;
	}
}